#include <stdio.h>
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdbool.h>

bool is_prime(int n) {
	if (n <= 1) {
		return false;
	}
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

bool is_palindrome(int m) {
	int temp = m;
	int reverse = 0;
	while (temp > 0) {
		reverse = reverse * 10 + temp % 10;
		temp = temp / 10;
	}
	return m == reverse;
}

int main() {
	int min = 0;
	int i = min;
	int max = 0;
	scanf("%d %d", &min, &max);
	for (i = min; i <= max; i++) {
		if (is_prime(i) && is_palindrome(i)) {
			printf("%d\n", i);
		}
	}
	return 0;
}